home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue27 / system / IDEIcons / uicon.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1997-10-03  |  1.9 KB  |  81 lines

  1. unit uicon;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   ComCtrls, StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     ListView1: TListView;
  12.     ImageList1: TImageList;
  13.     procedure FormCreate(Sender: TObject);
  14.   private
  15.     { Private declarations }
  16.   public
  17.     { Public declarations }
  18.   end;
  19.  
  20. var
  21.   Form1: TForm1;
  22.  
  23. implementation
  24.  
  25. {$R *.DFM}
  26.  
  27. const
  28.     IconNames: array [0..28] of PChar = (
  29.         'MainIcon',             'MainIconDCU',
  30.         'MainIconDFM',          'MainIconDPK',
  31.         'MainIconDPR',          'MainIconPAS',
  32.         'NewActiveX',           'NewApp',
  33.         'NewComp',              'NewData',
  34.         'NewDLL',               'NewForm',
  35.         'NewPackage',           'NewRemoteData',
  36.         'NewText',              'NewThread',
  37.         'NewUnit',              'Project',
  38.         'ProjectIcon',          'RepBothForm',
  39.         'RepMainForm',          'RepNewForm',
  40.         'RepNewProject',        'XAuto',
  41.         'XCtrl',                'XForm',
  42.         'XLib',                 'XProp',
  43.         'XTLib' );
  44.  
  45. procedure TForm1.FormCreate(Sender: TObject);
  46. var
  47.     Idx: integer;
  48.     hLib: hModule;
  49.  
  50.     procedure AddIcon (IconName: PChar);
  51.     var
  52.         Icon: TIcon;
  53.         Idx: Integer;
  54.         ListItem: TListItem;
  55.     begin
  56.         Icon := TIcon.Create;
  57.         try
  58.             Icon.Handle := LoadIcon (hLib, IconName);
  59.             Idx := ImageList1.AddIcon (Icon);
  60.             ListItem := ListView1.Items.Add;
  61.             ListItem.Caption := IconName;
  62.             ListItem.ImageIndex := Idx;
  63.         finally
  64.             Icon.Free;
  65.         end;
  66.     end;
  67.  
  68. begin
  69.     hLib := LoadLibrary ('c:\delphi 3.0\bin\delphi32.exe');
  70.     if hLib <> 0 then try
  71.         for Idx := Low(IconNames) to High(IconNames) do
  72.             AddIcon (IconNames [Idx]);
  73.     finally
  74.         FreeLibrary (hLib);
  75.     end;
  76. end;
  77.  
  78. end.
  79.  
  80.  
  81.